package com.example.shopping_web_back.mapper;

import com.example.shopping_web_back.pojo.Business;
import com.example.shopping_web_back.pojo.Goods;
import com.example.shopping_web_back.pojo.Result;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

//主要用于定义顾客(用户)的与数据库有关的操作
@Mapper
public interface BusinessMapper {

    //从顾客信息表中提取出指定顾客名字的所有信息
    @Select("select * from shoppingweb.business_information where name = #{businessName}")
    Business findByBusinessName(String businessName);

    //向顾客表中插入新的数据
    @Insert("insert into shoppingweb.business_information(name,password)" +
            " value(#{businessName},#{password})")
    void add(String businessName, String password);

    @Update("update shoppingweb.business_information set email=#{email}, telephone=#{telephone} where id = #{id}")
    void update(Business business);

    @Update("update  shoppingweb.business_information set image=#{imageUrl} where id = #{id}")
    void updateImage(String imageUrl, Integer id);

    @Update("update  shoppingweb.business_information set password=#{newPwd} where id = #{id}")
    void updatePassword(String newPwd, Integer id);

    @Select("select * from shoppingweb.goods_information where business = #{businessName}")
    List<Goods> searchAllGoods(String businessName);
}
